<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

	 private $base;//类的属性，根目录地址
	 private $view_common;//类的属性，参数
	 private $data;//类的属性，默认通用传递参数
	
	/*构造函数,类初始化时，被调用*/
	function __construct()
	{
		parent::__construct();
		$this->base = $this->config->base_url();
		$this->view_common = $this->config->item('view_common');
		$this->data = array_merge($this->view_common, array( 'url'=>$this->base ));
	}
	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		//$this->output->cache(10);//缓存语句，参数：缓存多少分钟
		$this->view('index');
	}
	
	/**
	 * 显示 Page for this controller.
	 *
	 * 显示公司介绍的各个页面
	 * 在application/config/routes.php页面继续路由设置：$route['welcome/(:any)'] = 'welcome/view/$1';
	 */
	public function view($page = 'index')
	{
		$list = array('index','about','register','registerdetail','reservation','map');
		if(!in_array($page, $list))
		{
			// 页面不存在
    		show_404();
		}
		$this->common_company_info( $page );
	}
	
	

	
	 
	
	/**
	 * 私有公共函数，显示公司信息
	 * 通过页面id，读取对应的页面内容，显示给用户
	 */ 
	private function common_company_info( $id )
	{
		$data = $this->data;
		$this->load->model('Company_info');
		$data['id'] = $id;
		$data = array_merge($this->Company_info->get_company_content($id), $data);
		
		$this->load->view('temples/head',$data);
		if(!in_array($id,array('about','map'))){
			$this->load->view('temples/round',$data);
		}
		$this->load->view('default/'.$id,$data);
		$this->load->view('temples/footer',$data);
	}
	
	//调用不存在的方法
	function __call($functionName,$args){
        show_404();
    }

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */